//
//  HomeFreshHotView.m
//  爱鲜蜂
//
//  Created by 廖易诚 on 16/8/31.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "HomeFreshHotView.h"
#import "FreshHotCell.h"
#import "HotSaleModel.h"


@interface HomeFreshHotView ()<UICollectionViewDataSource,UICollectionViewDelegate>

@end

@implementation HomeFreshHotView

- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout {
    if (self = [super initWithFrame:frame collectionViewLayout:layout]) {
        UICollectionViewFlowLayout *flowLayout = (UICollectionViewFlowLayout *)layout;
        
        flowLayout.itemSize = CGSizeMake((frame.size.width - 10 )*0.5, 180);
        flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
        flowLayout.minimumInteritemSpacing = 10;
        self.bounces = NO;
        self.showsVerticalScrollIndicator = NO;
        self.dataSource = self;
        self.delegate = self;
        
        [self registerClass:[FreshHotCell class] forCellWithReuseIdentifier:@"FreshHotCell"];
        self.backgroundColor = [UIColor colorWithRed:249/255.0 green:247/255.0 blue:247/255.0 alpha:1];
    }
    return self;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.datas.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    FreshHotCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"FreshHotCell" forIndexPath:indexPath];
    cell.model = self.datas[indexPath.item];
    
    return cell;
    
}

- (void)setDatas:(NSArray *)datas {
    _datas = datas;
    [self reloadData];
}

@end
